package com.chenwei.rabbit.routingTopic;

import com.chenwei.rabbit.workQueues.Person;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**rabbit-springboot整合后
 * 简单的直连模式，一个生产者一个队列一个消费者
 * @author: chenwei
 * @date: 2021/4/1 17:46
 */
@RestController("topicProvider")
public class Provider {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    @RequestMapping("/topic")
    public void sendMsg(){
        Person person = new Person();
        person.setName("topic");
        //参数1 交换机名称 参数2 路由key 参数3 要发送的消息
        for (int i = 0; i < 6; i++) {
            person.setAge(i);
            rabbitTemplate.convertAndSend("topicExchange","person.name.topic",person);
        }


    }

}
